-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(securitycenter): delete deprecated samples and update samples #13223
base: main
Are you sure you want to change the base?
Conversation
… warnings - Use same importing style for all datetime objects across samples - Use a timezone compatible with Python 3.9 (as datetime.UTC was added in Python 3.11) - Remove deprecation warning for utcnow() - Add debug prints to watch failing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @eapl-gemugami, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request addresses an internal issue (b/402176817) by unifying the syntax for datetime objects across the securitycenter samples, resolving deprecation warnings, and ensuring compatibility with Python 3.9. Specifically, it standardizes the import style for datetime objects, uses a timezone compatible with Python 3.9 (datetime.UTC was introduced in Python 3.11), and removes the deprecation warning associated with utcnow()
. Debug prints have also been added to aid in troubleshooting failing tests.
Highlights
- Datetime Syntax Unification: The pull request standardizes the way datetime objects are imported and used across the securitycenter samples.
- Python 3.9 Compatibility: The code is updated to use a timezone compatible with Python 3.9, as
datetime.UTC
was introduced in Python 3.11. - Deprecation Warning Removal: The deprecation warning for
utcnow()
has been removed. - Debugging Enhancements: Debug print statements have been added to assist in identifying and resolving failing tests.
Changelog
- securitycenter/snippets/snippets_findings.py
- Replaced
import datetime
withfrom datetime import datetime, timezone
for consistent datetime object handling. (lines 155, 197, 247, 291, 422, 543) - Replaced
datetime.datetime.now(tz=datetime.timezone.utc)
withdatetime.now(tz=timezone.utc)
for Python 3.9 compatibility. (lines 164, 228, 262, 311) - Replaced
datetime.now() - timedelta(days=5)
withdatetime.now(timezone.utc) - timedelta(days=5)
forfive_days_ago
variable. (line 439) - Added debug print statement for
five_days_ago
variable. (line 442) - Replaced
datetime.utcnow() - timedelta(days=1)
withdatetime.now(timezone.utc) - timedelta(days=1)
forread_time
variable. (line 561) - Added debug print statement for
read_time
variable. (line 564)
- Replaced
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Did you know?
The concept of time zones was largely popularized by the expansion of railways in the 19th century, as standardized time became essential for coordinating train schedules.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request aims to unify the syntax for datetime objects and remove deprecation warnings in the securitycenter snippets. The changes look good overall, addressing the specified issues. However, there are a couple of points that could be improved.
Summary of Findings
- Unnecessary debug prints: The debug prints added to watch failing tests should be removed before merging the pull request.
- TODO comments: The TODO comments indicating the debug prints should be removed should be addressed before merging the pull request.
Merge Readiness
The pull request is almost ready for merging. The core issue of unifying datetime syntax and removing deprecation warnings has been addressed. However, the debug prints and corresponding TODO comments should be removed before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.
- Fix linting problem when indicating Python interpreter on line 1 - Fix style
…uest contains an invalid argument.
- securitycenter_group_findings_with_changes - securitycenter_group_findings_at_time
- Try to remove "google.cloud.securitycenter.v1.Finding" has no field named "muteInfo"
…ycenter_v1' to make it explicit
…settings' to retry on Aborted exception
Here is the summary of changes. You are about to delete 2 region tags.
This comment is generated by snippet-bot.
|
Description
Fixes Internal: b/402176817
securitycenter_group_findings_with_changes
andsecuritycenter_group_findings_at_time
Update failing samples due to changes in API
securitycenter_list_findings_at_time
test_update_asset_discovery_org_settings
securitycenter
tosecuritycenter_v1
to make explicit which version is being usedsecuritycenter_receive_notifications
as in the Java sample, to ignore a ParsingError.Improvements to samples
snippet_findings.py
Checklist
nox -s py-3.9
(see Test Environment Setup) -> I'm missing a permission in in local environment, so will be only tested on Kokoro CI.nox -s lint
(see Test Environment Setup)